package c.a.md.androidvideo.gles.util;

import android.opengl.GLES20;

/**
 * Created by ytf on 2018/11/4 004.
 * Description:
 */
public class ShaderUtils
{
    public static int createShader(int type, String shaderCode)
    {
        int shader = GLES20.glCreateShader(type);
        GLES20.glShaderSource(shader, shaderCode);
        GLES20.glCompileShader(shader);
        return shader;
    }

    public static int handleProgram(int... shaders)
    {
        if(shaders != null && shaders.length > 0)
        {
            int program = GLES20.glCreateProgram();
            for (int i = 0; i < shaders.length; i++)
            {
                GLES20.glAttachShader(program, shaders[i]);
            }
            GLES20.glLinkProgram(program);
            return program;
        }
        return -1;
    }
}
